package com.hue.springbootrabbit.controller;

import com.hue.springbootrabbit.domain.User;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 姚凤桥
 * @Date 2022/1/4 15:47
 * @Description:
 */
@RestController
@RequestMapping("/test")
public class TestController {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("send")
    public String send() {
        User user = new User("张三", "男", 20);
        rabbitTemplate.convertAndSend("test.exchange", "test", user);
        return "发送消息成功";
    }
}
